package com.robot.base.util;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;

import com.robot.base.configs.AppConstants;
import com.robot.base.model.MemberAdapterBean;

import java.util.List;

public class LiveDataEventManager {

    public static void postLoginSuccessEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).postValue("");
    }

    public static void observerLoginSuccessEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).observe(owner, observer);
    }

    public static void postPlayCourseEvent(String url) {
        LiveDataBus.get().with(AppConstants.LiveKey.COURSE_PLAY).postValue(url);
    }

    public static void observerPlayCourseEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.COURSE_PLAY).observe(owner, observer);
    }


    public static void postCommentSuccessEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).postValue("");
    }

    public static void observerCommentSuccessEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.LOGIN_SUCCESS).observe(owner, observer);
    }


    public static void postRefreshTeamEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_TEAM).postValue("");
    }

    public static void observerRefreshTeamEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_TEAM).observe(owner, observer);
    }

    public static void postRefreshMemberEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_MEMBER).postValue("");
    }

    public static void observerRefreshMemberEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_MEMBER).observe(owner, observer);
    }

    public static void postRefreshLabelEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_LABEL).postValue("");
    }

    public static void observerRefreshLabelEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_LABEL).observe(owner, observer);
    }

    public static void postSelectTagMemberEvent(List<MemberAdapterBean> memberAdapterBeans) {
        LiveDataBus.get().with(AppConstants.LiveKey.SELECT_TAG_MEMBER).postValue(memberAdapterBeans);
    }

    public static void observerSelectTagMemberEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.SELECT_TAG_MEMBER).observe(owner, observer);
    }

    public static void postRefreshProjectProfileMemberEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_PROJECT_PROFILE_MEMBER).postValue("");
    }

    public static void observerRefreshProjectProfileMemberEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_PROJECT_PROFILE_MEMBER).observe(owner, observer);
    }

    public static void postRefreshProjectProfileEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_PROJECT_PROFILE).postValue("");
    }

    public static void observerRefreshProjectProfileEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_PROJECT_PROFILE).observe(owner, observer);
    }

    public static void postRefreshProjectListEvent() {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_PROJECT_LIST).postValue("");
    }

    public static void observerRefreshProjectListEvent(LifecycleOwner owner, @NonNull Observer<Object> observer) {
        LiveDataBus.get().with(AppConstants.LiveKey.REFRESH_PROJECT_LIST).observe(owner, observer);
    }
}
